Lg.Select

This command is deprecated. Do not use it in new code as we may remove it in the future!

This command selects a specific segment of a LEGIC Prime card and reads some data from it.

This command can both access IM cards (standard LEGIC Prime cards containing user data) and SAM cards (used for security purposes).

If no label can be detected, the Lg.Idle command is implicitly called in order to switch off the HF field. Otherwise, the selected label will stay selected until either a new call of the Lg.Select command is performed, until the Lg.Idle command is called, if the selected MIM gets out of the HF field, or if the Lg.ErrDataCorrupt error occurs.

If several segments are present on the card, only the first segment is directly accessible by the reader. All other segments have to be found by "jumping" from segment to segment. Therefore the time for selecting a certain segment is:

t = 80 ms + SegID * 22 ms

If several segments on the selected card must be accessed, it is recommended to always start with the segment which has the lowest ID.

The protocol header-based addressing mode should always be used. The physical addressing mode is only applicable for unsegmented MIMs and is therefore deprecated.

If the desired data is protected against reading, then the first 5 Bytes of the segment, according to the protocol header addressing, will be returned in the Data variable instead of the requested data. It is recommended to check that the returned value of Data has a length unequal to 5 or to check the value of the returned address in the ActAdr variable to make sure that the requested data has been properly returned.

If an error status code is returned by this command, no card will be selected.

If Lg.ErrBusy is returned, the reader is still busy with reading a SAM card. This occurs when the TO parameter for this command is to small to wait for the end of this operation. In this case, the reader will reject any LEGIC command by returning the Lg.ErrBusy status code until the operation is finished and the stamp is stored in the reader's EEPROM.

To prevent unauthorized writing of stamp data to the reader's EEPROM, it is advisable to use a TO value below 0xA0 in your application software.

Properties

Parameters (request frame)

Name Type/Size Description
TO Integer (8 bits)

The command timeout is calculated by

TO * 100 ms

TO should be chosen depending on the location of the desired card segment. The default value (0x05) is sufficient for most purposes, but a value > 0xA0 is required to read SAM cards.

Adr Integer (16 bits) Start address of data on card to read. The default value (7) is the address of the card's serial number.
Len Integer (8 bits) Length of data to read, in Bytes. The default value (4) is the length of the card's serial number.
PollTime Integer (8 bits)

The required poll time is calculated by

Time * 20 ms

The default value (0x01) is sufficient for most purposes.

CRCAdr Integer (16 bits) Address of the CRC checksum of the data stored at Adr.
Mode Bit mask (8 bits) -
RFU Integer (bit mask area 0xE0) Zero padding
SafeDat Integer (bit 0x10) If set, the safe data handling mechanism will be used. This mechanism detects if two cards are in the HF field at the same time and returns an error if this is the case.
ChgSeg Integer (bit 0x08) If set, a new segment on the already selected card is directly selected without going back to the idle state beforehand. This saves time and ensures that the new segment is located on the already selected card.
ProtHead Integer (bit 0x04) If set, use protocol header for addressing, otherwise use physical addresses. For segmented cards, protocol header is mandatory. The chosen addressing mode impacts all following commands working on the currently selected card.
CRCCalc Integer (bit 0x02) If set, use 16 bit CRC checksum, otherwise 8 bit. 16 bit CRC is only available when the ProtHead flag is also set.
CRCChk Integer (bit 0x01) Enable/disable CRC check.
SegID Integer (8 bits) ID of desired segment (or start segment for segment search).
Stamp Raw data (until end of frame) Stamp Bytes that may be used for selecting a certain segment instead of the segment ID. In this case, the SegID parameter will be used as the start segment for the search. Segments are always searched beginning from the lowest ID.

Returned values (response frame)

Name Type/Size Description
MediaType Enumeration (8 bits) Indicates the type of card that was selected.
Values:
  • GAM (0x01)
  • SAM (0x02)
  • IAM (0x03)
  • IM (0x04)
  • NM (0x05)
  • XAM1 (0x06)
FuncLevel Integer (8 bits)

Function level of the card. The function level depends on the type of card:

  • 1-16: GAM (General Authorization Media)
  • 1-64 (55-64 reserved by LEGIC): SAM (System Authorization Media)
  • 1-48 (40-48 reserved by LEGIC): IAM (Identification Authorization Media)
  • 0: IM (Identification Media, segmented/unsegmented) / NM (New Media)
  • 1: XAM (Extended Authorization Media)
OrgLevel Integer (8 bits)

Organization level of the card. The organization level depends on the type of card:

  • 1-12: AM (Authorization Media) / XAM (Extended Authorization Media)
  • 0: IM (Identification Media) / NM (New Media)
EvStat Enumeration (8 bits) Event Status of operation.
Values:
  • OKNoEvent (0x00)
    OK / no event.
  • EEPROMFull (0x01)
    EEPROM for stamp data already full.
  • StampToEEPROM (0x02)
    Stamp data added to EEPROM.
  • SamOutOfHF (0x03)
    Storing stamp data aborted because SAM out of HF field.
  • NoStampOnSAM (0x04)
    No stamp data available on SAM.
  • StampDeleted (0x05)
    Stamp data deleted.
  • StampDeletionAborted (0x06)
    Deletion of stamp aborted because SAM out of HF field.
  • StampAlreadyInEEPROM (0x07)
    Stamp already in EEPROM.
  • StampNotStoredToEEPROM (0x08)
    Stamp data was not stored to EEPROM.
  • NewStampExtended (0x09)
    New stamp data with extended stamp Bytes was stored to EEPROM.
ActSegID Integer (8 bits) Selected segment, 0x01 - 0x7F for segmented card, 0x00 for unsegmented card.
ActAdr Integer (16 bits) Address of read data.
Length of Data Integer (8 bits) Length of Data in bytes
Data Raw data Data read from card.